import { _decorator, Component, Node, TextAsset } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('ProtoMgr')
export class ProtoMgr extends Component {
    public static Instance: ProtoMgr = null;

    @property(TextAsset)
    private pbTextAsset: TextAsset = null;

    // private pb: any = null;
    // onLoad(): void {
    //     if (ProtoMgr.Instance === null) {
    //         ProtoMgr.Instance = this;
    //     } else {
    //         this.destroy();
    //         return;
    //     }
    //     this.pb = protobuf.parse(this.pbTextAsset, { keepCase: true, enums: String })
    //     plog("++++++", this.pb.root)
    // }

    // public SerializeMsg(msgName, msgBody): Uint8Array {
    //     // plog(msgBody);
    //     let rs = this.pb.root.lookupType(msgName);
    //     let msg = rs.create(msgBody);

    //     let buf = rs.encode(msg).finish();

    //     return buf;
    // }

    // public DeserializeMsg(msgName, msgBuf: Uint8Array): any {
    //     let rs = this.pb.root.lookupType(msgName);
    //     let msg = rs.decode(msgBuf)
    //     return msg;
    // }

}